<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>动态数据</title>
</head>
<body>
<ul id="city">

</ul>
<script type="text/javascript">
    // 真正的时候并不是写死了的 动态获取时会利用发送接受网络请求获得数据
    var city_lt = ["北京", "上海", "河北","山西"];

    for (var i = 0; i < city_lt.length; i++) {
        var txt = city_lt[i];

        //创建li标签
        var tag = document.createElement("li");
        //写入内容
        tag.innerText = txt;
        // 添加到id=city的标签下
        var parentTag = document.getElementById("city");
        parentTag.appendChild(tag);
    }
</script>
</body>
</html>